package com.apes.crm.vip.base;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * 功能：会员类型
 *
 * @author HuJianlin
 * @create 2018-03-16 16:00
 */
@Getter
@Setter
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = "crm_vip_type")
public class VipType extends Model {

    @Id
    @Column(name = "id", length = 16)
    @Comment("会员类型编码")
    private String id;  //会员类型编码

    @Column(name = "name", nullable = false, length = 120)
    @Comment("会员类型名称")
    private String name; //会员类型名称

    @Column(name = "is_corporate", nullable = false, columnDefinition = "number(1,0) default 0")
    @Comment("单位会员标记")
    private boolean corporate = true; //单位会员标记

    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "company_id", referencedColumnName = "id")
    @Comment("所属公司")
    private PartyRole company; //所属公司

    @Column(name = "DESCRIPTION", length = 200)
    @Comment("描述")
    private String description; //描述

    @Column(name = "max_cars", nullable = false)
    @Comment("最高车辆数")
    private int maxCars = 0;  //最高车辆数

    @Column(name = "valid", nullable = false, columnDefinition = "number(1,0) default 1")
    @Comment("是否有效")
    private boolean valid = true; //有效

}
